<?php
class Merchant_Model_ProductPackageMap
{
	protected $_table;
	
	public function __construct(){
		$this->_table = new Merchant_Model_DbTable_ProductPackageMap();
	}
	
	public static function getInstance(){
		return new Merchant_Model_ProductPackageMap();
	}
	
	/**
	* 获得dbtable对象
	* @return Zend_Db_Table_Abstract
	*/
	public function getDbTable(){
		return $this->_table;
	}
	public function getAdapter(){
		return $this->_table->getAdapter();
	}
	
	public function add($row){
		$row['ppm_last_update'] = date("Y-m-d H:i:s");
		return $this->_table->insert($row);
	}
	
	public  function update($row,$value,$field='product_id'){
		$row['ppm_last_update'] = date("Y-m-d H:i:s");
		$where = $this->_table->getAdapter()->quoteInto("{$field} = ?",$value);
		return $this->_table->update($row, $where);
	}
	public function getPackage($val,$file='product_id'){
		$where = $this->_table->getAdapter()->quoteInto("$file = ?",$val);
		return $this->_table->fetchRow($where);
	}
	
	public function delete($value,$field='product_id'){
		$where = $this->_table->getAdapter()->quoteInto("{$field} = ?", $value);
		return $this->_table->delete($where);
	}
}